import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:audioplayers/audioplayers.dart';
import 'package:speed_random/app_styles.dart';
import 'package:speed_random/common/common_fuc.dart';
import 'package:speed_random/pages/home/rand_com/rand_com_args.dart';
import 'package:speed_random/pages/home/rand_com/view_set.dart';
import 'package:speed_random/pages/home/spin_bottle/view_set.dart';
import 'package:speed_random/widgets/row_two_buttons.dart';

import 'logic.dart';
import 'state.dart';

class SpinBottleList extends StatelessWidget {
  SpinBottleList({Key? key}) : super(key: key);
  
  @override
  Widget build(BuildContext context) {
var randomNumbers=[
  {"name":"🖊️","color":"#eeeeee"},
  {"name":"🖋️","color":"#e9e7ef"},
  {"name":"🖌️","color":"#fcc8f8"},
  {"name":"🖍️","color":"#fff2df"},
  {"name":"🔨","color":"#d6ecf0"},
  {"name":"🗡️","color":"#f2ecde"},
  {"name":"🏹","color":"#fcefe8"},
  {"name":"💉","color":"#fff2df"},
  {"name":"🥄","color":"#88ada6"},
  {"name":"🍼","color":"#0aa344"},
  {"name":"🍭","color":"#c0ebd7"},
  {"name":"🏏","color":"#ffb3a7"},
  {"name":"👈","color":"#8d4bbb"},
  {"name":"👍","color":"#815463"},
  {"name":"👉","color":"#4c221b"},
];
    return Scaffold(
      appBar: AppBar(
        title: Text("旋转".tr),
       // backgroundColor: AppStyles.colorAppBarbg,
        actions: [
          /*IconButton(
            icon: const Icon(Icons.history),
            onPressed: () {
              Get.to(() => ComResultsPage(),arguments: Get.arguments); // 跳转到历史页面
            },
          ),*/
        ],
      ),
      body:  GridView.builder(
        padding: const EdgeInsets.all(10),
        // 限制滚动，避免与 Scaffold 滚动冲突
        shrinkWrap: true,
        // 每行显示 2 列
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          // 水平间距
          crossAxisSpacing: 10.0,
          // 垂直间距
          mainAxisSpacing: 10.0,
        ),
        // 设置列表项数量
        itemCount: randomNumbers.length,
        // 构建每个列表项
        itemBuilder: (context, index) {
          final itemObj = randomNumbers[index];
          final indexnum = index+1;
          return GestureDetector(
            onTap: () {
              // 处理点击事件
              Get.toNamed('/spin_bottle', arguments: RandComArgs(
                title: "旋转".tr+itemObj["name"]!,
                list:itemObj["name"]!,
                cachekey: "spin_bottle",
                colorPagebg: commonFuc.hexToColor(itemObj["color"]!), // 添加背景色参数
                colorPageText: Color(0xff101010), // 添加文字颜色参数
              ).toMap());
            },
            child: Center(
              child: Container(
                // 添加边框
                decoration: BoxDecoration(
                  color:commonFuc.hexToColor(itemObj["color"]!),
                  border: Border.all(
                    color: commonFuc.hexToColor("#155263"),
                    width: 1,




                  ),
                  borderRadius: BorderRadius.circular(10),
                ),
                padding: const EdgeInsets.all(5),
                //margin:  EdgeInsets.only(left: index%2==0?10:0, right: index%2==0?0:10, top: 10, bottom: 0),
                child:Center(
                  child: Text(
                    itemObj["name"]!,
                    style: TextStyle(
                      fontSize: 40,
                      color: AppStyles.colorPageText,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),

            ),
          );
        },
      ),
    );
  }
}
